package com.syq.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.syq.annotation.RequiresPermissionsDesc;
import com.syq.pojo.DtsRegion;
import com.syq.service.DtsRegionService;
import com.syq.util.ResponseUtil;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.omg.PortableInterceptor.INACTIVE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: RegionController
 * @Description: TODO
 * @Create by: syq
 * @Date: 2022/7/26 8:45
 */

@RestController
@RequestMapping("/admin/region")
@CrossOrigin
public class RegionController {

    @Autowired
    private DtsRegionService dtsRegionService;

    @RequiresPermissionsDesc(menu = {"商场管理","行政区域"},button = "查询")
    @RequiresPermissions(value = "admin:region:list")
    @GetMapping("/list")
    public Object list(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit,String name, Integer code){
        Map<String,Object> map=new HashMap<>();
        IPage<DtsRegion> regionIPage=dtsRegionService.findByPage(page,limit,code,name);
        map.put("total",regionIPage.getTotal());
        map.put("items",regionIPage.getRecords());
        return ResponseUtil.ok(map);
    }
}
